package com.banciyuan.bcywebview.biz.post.uploadpic.receiver;

import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;

import de.greenrobot.daoexample.model.Multi;

/**
 * Created by squall on 2017/4/12.
 */

public class UploaderReceiver extends BroadcastReceiver {

    private UploaderLoaderInter uploaderLoaderInter;

    public UploaderReceiver(UploaderLoaderInter uploaderLoaderInter) {
        this.uploaderLoaderInter = uploaderLoaderInter;
    }

    @Override
    public void onReceive(Context context, Intent intent) {
        if (intent.getAction().equals(UploaderLoaderInter.PROGRESS_KEY)) {
            uploaderLoaderInter.onProgress(intent.getDoubleExtra("progress", 0d), intent.getStringExtra("key"));
        } else if (intent.getAction().equals(UploaderLoaderInter.UPLOAD_FINISH_KEY)) {
            uploaderLoaderInter.onFinish((Multi) intent.getSerializableExtra("Multi"));
        } else if (intent.getAction().equals(UploaderLoaderInter.UPLOAD_FAIL_KEY)) {
            uploaderLoaderInter.onFail();

        }
    }
}
